Repository navigation
test(hibernate): pin where() creation, nested left-join subqueries, save(validate: false) and composite index order - #16847
borinquenkid wants to merge 4 commits into
Conversation
…ueries Creating a detached where() query that joins a collection runs no SQL, and a left join inside a nested where() subquery keeps the rows matched only through the primary site, in both bindings. Closes #14425 Closes #14422 Claude-Session: https://claude.ai/code/session_01Dmki4SQGwRSj8pRJ5KCWyX
… and externally-run dialects Related to #15276 Claude-Session: https://claude.ai/code/session_01Dmki4SQGwRSj8pRJ5KCWyX
…y-run dialects Properties naming the same index give a composite index in declaration order on H2 (both bindings) and on PostgreSQL, MySQL and MariaDB (H7). Document the behavior under the column mapping reference. Related to #14424 Claude-Session: https://claude.ai/code/session_01Dmki4SQGwRSj8pRJ5KCWyX
jamesfredley
left a comment
There was a problem hiding this comment.
Not approving. The note says the index follows the mapping block. It follows the field order.
| * `comment` (optional) - The comment for the column (used to create the table DDL) | ||
| * `defaultValue` (optional) - The database default value | ||
|
|
||
| Properties that name the same `index` share one composite index. The columns appear in the index in the order the properties are declared in the mapping block, so this declaration creates an index on `(token, address)`: |
There was a problem hiding this comment.
address is declared after token, and the mapping names address first in the shared index. The index is still (token, address). Do not say the mapping block sets the order.
There was a problem hiding this comment.
Fixed in 650d024. The class declaration order decides, whatever order the mapping block names the properties in, and the reference now says so, with the example reversed. The specs pin it: address named before token in the mapping, and a three-column index named chain, address, token, on Hibernate 5 and 7, and on real PostgreSQL, MySQL and MariaDB containers. All pass.
… and the specs pin it The reference said the columns of a shared index follow the order of the mapping block. They follow the order the properties are declared in the class. The specs now name the properties in a different order in the mapping block (two columns on the default and the container databases, three on Hibernate 5 and 7), and the example in the reference shows it. Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
jamesfredley
left a comment
There was a problem hiding this comment.
The composite index still follows the declaration order, and the note says the same.
✅ All tests passed ✅🏷️ Commit: 650d024 Learn more about TestLens at testlens.app/docs. |
Regression tests for long-open issues that already behave correctly in both the Hibernate 5 and Hibernate 7 bindings. There is no production change.
Creating (without executing) a detached Criteria (with a .where{..}) can cause
select count(*)queries to run #14425 Creating a detachedwhere {}query that joins a collection runs no SQL, and the query still returns the right rows when it is run.How to use join on nested association? #14422 A left join inside a nested
wheresubquery keeps the rows matched only through the primary site.save(validate: false) still validates on flush #15276 An instance saved with
validate: false, flush: trueis persisted, and a later valid save still flushes. Covered on H2 in both bindings, and on PostgreSQL, MySQL and MariaDB for Hibernate 7 (skipped when Docker is unavailable). The issue is left open: it records the Grails 7.0.4 behavior change that the thread is still discussing.How to define composite index order ? #14424 Properties that name the same
indexgive a composite index whose columns follow declaration order. Covered on H2 in both bindings and on PostgreSQL, MySQL and MariaDB for Hibernate 7. Thecolumnreference now documents it. The issue is left open for the reporter to confirm.Closes #14425
Closes #14422
Related to #15276
Related to #14424
https://claude.ai/code/session_01Dmki4SQGwRSj8pRJ5KCWyX